<?php
set_time_limit(24*86400);
ini_set('memory_limit', '512M');
require_once('config.php');
ob_start();
require_once("../classes/amazon_ses.php");
require_once("../amazon-sdk/sdk.class.php");
ob_clean();
$from = 'mail.sudo.vn@gmail.com';
$title = 'Test email amazon ses của Sudo';
$attach_file = '';
//key và secret trên ses
$AWS_KEY ='AKIAIA6FKW6GY7DVQFHA';
$AWS_SECRET_KEY = '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';

$arr_email = 'caotu@ymail.com';
$content = '
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hoc123.vn - Học Tiếng Anh Online</title>
<style>
* {
    margin:0;
    padding: 0;
}
li {
    list-style: none;
}
a {
    text-decoration: none;
}
</style>
</head>
<body>
    <div class="wrap" style="width: 600px; margin: 0px auto;">
        <div class="header" style="width: 100%; height: 76px; background: url(http://hoc123.vn/themes_v2/images/bot_head_bg.jpg);">
            <div class="logo" style="width: 168px; height: 100%; float: left;">
                <img alt="hoc123.vn" style="width: 142px; height: 50px; margin: 15px;" src="http://hoc123.vn/themes_v2/images/logo_new.png" alt="Hoc123.vn - Học tiếng anh online - Học tiếng anh chất lượng cao" />
            </div>
            <div class="banner" style="width: 432px; height: 100%; float: left;">
                <ul class="follow" style="height: 22px; width: 120px; float: right; margin-top: 12px; background: url(http://hoc123.vn/themes_v2/images/email_icon_social.png) no-repeat center">
                    <li><a href="https://www.facebook.com/ngoainguvui?fref=ts" style="display: block; width: 20px; height: 20px; float: left; margin-left: 10px; text-indent: -9999em;"></a></li>
                    <li><a href="https://twitter.com/vuihoctienganh" style="display: block; width: 20px; height: 20px; float: left; margin-left: 10px; text-indent: -9999em;"></a></li>
                    <li><a href="https://plus.google.com/114778330048673291965/post" style="display: block; width: 20px; height: 20px; float: left; margin-left: 10px; text-indent: -9999em;"></a></li>
                    <li><a href="mailto:tintuchoc123.vn@gmail.com" style="display: block; width: 20px; height: 20px; float: left; margin-left: 10px; text-indent: -9999em;"></a></li>
                </ul>
                <ul class="nav" style="height: 30px; width: 100%; margin-top: 44px;">
                    <li><a href="http://hoc123.vn/khoa-hoc/2-tieng-anh-giao-tiep.html" style="display: block; height: 30px; line-height: 30px; float: right; padding: 0px 10px; color: #fff;">TA giao tiếp</a></li>
                    <li><a href="http://hoc123.vn/khoa-hoc/37-tieng-anh-pho-thong.html" style="display: block; height: 30px; line-height: 30px; float: right; padding: 0px 10px; color: #fff;">TA phổ thông</a></li>
                    <li><a href="http://hoc123.vn/khoa-hoc/1-tieng-anh-van-phong.html" style="display: block; height: 30px; line-height: 30px; float: right; padding: 0px 10px; color: #fff;">TA văn phòng</a></li>
                    <li><a href="http://hoc123.vn/khoa-hoc/197-tieng-anh-tre-em.html" style="display: block; height: 30px; line-height: 30px; float: right; padding: 0px 10px; color: #fff;">TA trẻ em</a></li>
                </ul>
            </div>
        </div>
        <div class="noti" style="width: 100%; height: 50px; margin-top: 20px; background: url(http://hoc123.vn/themes_v2/images/bg_yellow.jpg);">
            <h2 style="width: 470px; padding-left: 20px; height: 50px; line-height: 50px; float: left; color: #1a5951;font-size: 14px;">Announcement season offer manger to other etc</h2>
            <a href="http://hoc123.vn" style="display: block; width: 102px; height: 34px; line-height: 34px; margin-top: 8px; float: left; color: #fff; text-align: center; background: url(http://hoc123.vn/themes_v2/images/bg_cyan.jpg); border-bottom: 2px solid #097369;box-sizing: border-box; border-radius: 6px;">Call to Action</a>
        </div>
                    <div class="course" style="width: 570px; height: 160px; padding: 15px; margin-top: 20px; background: #f3f3f3">
                <div class="img" style="width: 230px; height: 155px; float: left; margin-right: 12px; overflow: hidden;">
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-kinh-doanh-ta-kinh-doanh-intermediate/intermediate-2/85-516-main.html"><img style="width: 230px; height: 155px;" src="http://hoc123.vn/pictures/courses/medium_int1353053439.jpg"/></a>
                </div>
                <div class="content" style="width: 275px; height: 155px; float: left; margin-right: 12px;">
                    <h2 style="font-size: 18px; line-height: 1em; color: #35b2aa;">Intermediate 2</h2>
                    <p style="font-size: 14px; color: #656565; margin-top: 10px;"> Kh&oacute;a học gi&uacute;p bạn tiếp tục củng cố v&agrave; n&acirc;ng cao những kiến thức tiếng anh trong m&ocirc;i trường kinh doanh th&ocirc;ng qua c&aacute;c b&agrave;i học với ...</p>
                    <h5 style="font-size: 14px; color: #fd8800; margin-top: 10px;">380 người đã đăng ký</h5>
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-kinh-doanh-ta-kinh-doanh-intermediate/intermediate-2/85-516-main.html" style="display: block; width: 130px; height: 30px; line-height: 30px; margin-top: 8px; float: left; color: #fff; text-align: center; background: #34b2a6; border-radius: 4px;">Học thử ngay</a>
                </div>
            </div>
                    <div class="course" style="width: 570px; height: 160px; padding: 15px; margin-top: 20px; background: #f3f3f3">
                <div class="img" style="width: 230px; height: 155px; float: left; margin-right: 12px; overflow: hidden;">
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-pho-thong-trung-hoc-pho-thong/lop-12/180-1225-main.html"><img style="width: 230px; height: 155px !important;" src="http://hoc123.vn/pictures/courses/medium_mfn1357122200.jpg"/></a>
                </div>
                <div class="content" style="width: 275px; height: 155px; float: left; margin-right: 12px;">
                    <h2 style="font-size: 18px; line-height: 1em; color: #35b2aa;">Lớp 12</h2>
                    <p style="font-size: 14px; color: #656565; margin-top: 10px;"> Tiếng Anh 12 được bi&ecirc;n soạn dựa theo chương tr&igrave;nh tiếng Anh THPT của Bộ Gi&aacute;o Dục v&agrave; Đ&agrave;o Tạo. Kh&oacute;a học gồm c&oacute; 16 b&agrave;i học, mỗi ...</p>
                    <h5 style="font-size: 14px; color: #fd8800; margin-top: 10px;">517 người đã đăng ký</h5>
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-pho-thong-trung-hoc-pho-thong/lop-12/180-1225-main.html" style="display: block; width: 130px; height: 30px; line-height: 30px; margin-top: 8px; float: left; color: #fff; text-align: center; background: #34b2a6; border-radius: 4px;">Học thử ngay</a>
                </div>
            </div>
                    <div class="course" style="width: 570px; height: 160px; padding: 15px; margin-top: 20px; background: #f3f3f3">
                <div class="img" style="width: 230px; height: 155px; float: left; margin-right: 12px; overflow: hidden;">
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-van-phong-ta-van-phong-advance/advanced-1/21-46-main.html"><img style="width: 230px; height: 155px;" src="http://hoc123.vn/pictures/courses/medium_cwu1356684997.jpg"/></a>
                </div>
                <div class="content" style="width: 275px; height: 155px; float: left; margin-right: 12px;">
                    <h2 style="font-size: 18px; line-height: 1em; color: #35b2aa;">Advanced 1</h2>
                    <p style="font-size: 14px; color: #656565; margin-top: 10px;"> Kh&oacute;a học n&agrave;y sẽ trang bị cho học vi&ecirc;n kĩ năng giải th&iacute;ch li&ecirc;n quan đến dự &aacute;n, kế hoạch. </p>
                    <h5 style="font-size: 14px; color: #fd8800; margin-top: 10px;">449 người đã đăng ký</h5>
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-van-phong-ta-van-phong-advance/advanced-1/21-46-main.html" style="display: block; width: 130px; height: 30px; line-height: 30px; margin-top: 8px; float: left; color: #fff; text-align: center; background: #34b2a6; border-radius: 4px;">Học thử ngay</a>
                </div>
            </div>
                    <div class="course" style="width: 570px; height: 160px; padding: 15px; margin-top: 20px; background: #f3f3f3">
                <div class="img" style="width: 230px; height: 155px; float: left; margin-right: 12px; overflow: hidden;">
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-giao-tiep-ta-giao-tiep-upper-intermediate/upper-intermediate-4/226-1681-main.html"><img style="width: 230px; height: 155px;" src="http://hoc123.vn/pictures/courses/medium_vvu1375064873.jpg"/></a>
                </div>
                <div class="content" style="width: 275px; height: 155px; float: left; margin-right: 12px;">
                    <h2 style="font-size: 18px; line-height: 1em; color: #35b2aa;">Upper intermediate 4</h2>
                    <p style="font-size: 14px; color: #656565; margin-top: 10px;"> Kh&oacute;a học tiếng Anh cung cấp kiến thức về c&aacute;c vấn đề h&agrave;ng ng&agrave;y Daily issues. </p>
                    <h5 style="font-size: 14px; color: #fd8800; margin-top: 10px;">371 người đã đăng ký</h5>
                    <a href="http://hoc123.vn/khoa-hoc/tieng-anh-giao-tiep-ta-giao-tiep-upper-intermediate/upper-intermediate-4/226-1681-main.html" style="display: block; width: 130px; height: 30px; line-height: 30px; margin-top: 8px; float: left; color: #fff; text-align: center; background: #34b2a6; border-radius: 4px;">Học thử ngay</a>
                </div>
            </div>
                <div class="survey" style="margin: 20px 0px; width: 556px; padding: 10px 20px; border: 2px solid #31b5a7; background: #f3f3f3;">
            <h2 style="font-size: 18px; font-weight: normal; color: #31b5a7; padding: 0px 0px 5px 0px; margin: 0px;">Làm khảo sát của Hoc123.vn để học miễn phí trên Hoc123.vn</h2>
            <p style="font-size: 16px; color: #666; padding: 0px; margin: 0px;">Chỉ mất <span style="font-size: 24px; color: #666; padding: 0px 10px;">1 phút</span> học miễn phí <span>1 tuần</span> <a href="http://hoc123.vn/khao-sat.html" style="width: 140px; height: 30px; line-height: 30px; float: right; display: block; text-align: center; text-decoration: none; text-transform: uppercase; color: #fff; background: #fd8900;">Làm ngay</a></p>
        </div>
    </div>
</body>
</html>';
$amazonSes = new AmazonSES(array( "key" => $AWS_KEY, "secret" => $AWS_SECRET_KEY, "certificate_authority" => false ));
$asm = new AmazonSesMessage();
$asm->setFrom($from);

try {
   $asm->setTo($arr_email);
} 
catch(Exception $e) {
   echo 'Sai định dạng email: ' . $e->getMessage();
   die;
}

$asm->setSubject($title);
$asm->setMessage($content);

if ($attach_file != '') {
   try {
       $asm->attachFile($attach_file);
   } catch(Exception $e) {
       echo 'Lỗi khi gửi file đính kèm: ' . $e->getMessage();
       die;
   }
}

// Send email
$response =  $asm->sendEmail($amazonSes);

// Get response info
$response_info = $asm->getResponseInfo();
//Nếu thành công
if($response_info['http_code'] == 200) {
   echo 'Thành công';
}else {
   echo 'Gửi ko thành công <br />';
   dump($response_info);
}
    
?>